import SwiftUI
import Speech

struct ContentView: View {
    @StateObject private var speechManager = SpeechRecognitionManager()
    
    var body: some View {
        VStack {
            Text(speechManager.transcript)
                .padding()
            
            Button(speechManager.audioEngine.isRunning ? "停止" : "开始") {
                if speechManager.audioEngine.isRunning {
                    speechManager.stopRecording()
                } else {
                    try? speechManager.startRecording()
                }
            }
        }
        .onAppear {
            requestSpeechAuthorization()
        }
    }
}